package Collection;

import java.util.Arrays;
import java.util.List;

public class ArrayToList {
    public static void main(String[] args) {
        String[]array={"1","2","3","4","5"};
        System.out.println("array:"+ Arrays.toString(array));

        List<String> list=Arrays.asList(array);
        System.out.println("list:"+list);

        array[1]="6";
        System.out.println("arrys:"+Arrays.toString(array));
        System.out.println("list:"+list);
//对集合操作后，数组也会做相应的改变
        list.set(2,"7");     //将集合的第3个元素修改为7
        System.out.println("arrys:"+Arrays.toString(array));
        System.out.println("list:"+list);

        //给集合添加/删除元素相当于给数组添加/删除元素
        //而数组是定长的，不会自动扩容/缩容，因此发生不支持操作
        list.add("!!!");
    }
}
